package com.tj.jinzao.activity;


import android.widget.ImageView;

import com.tj.jinzao.R;
import com.tj.jinzao.base.BaseActivity;
import com.tj.jinzao.common.Settings;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 网络设置页面
 * Created by wjy on 2019/1/5.
 */
public class NetworkSettingActivity extends BaseActivity {

    @BindView(R.id.iv_wifi)
    ImageView mWifiView;
    @BindView(R.id.iv_3g)
    ImageView m3GView;

    private boolean mWifiOpen, m3GOpen;


    @Override
    public int getLayoutResource() {
        return R.layout.activity_network_setting;
    }

    @Override
    protected int getLeftButtonResId() {
        return R.mipmap.ic_back;
    }

    @Override
    protected void setupView() {
        super.setupView();
        mWifiOpen = Settings.getBoolean(this, Settings.KEY_PREF_WIFI_AUTO_PLAY, true);
        m3GOpen = Settings.getBoolean(this, Settings.KEY_PREF_3G_AUTO_PLAY, false);
        mWifiView.setImageResource(mWifiOpen ? R.mipmap.setting_check_on : R.mipmap.setting_check_off);
        m3GView.setImageResource(m3GOpen ? R.mipmap.setting_check_on : R.mipmap.setting_check_off);
    }

    @OnClick(R.id.iv_wifi)
    void changeWifi() {
        mWifiOpen = !mWifiOpen;
        Settings.setBoolean(this, Settings.KEY_PREF_WIFI_AUTO_PLAY, mWifiOpen);
        mWifiView.setImageResource(mWifiOpen ? R.mipmap.setting_check_on : R.mipmap.setting_check_off);
    }

    @OnClick(R.id.iv_3g)
    void change3G() {
        m3GOpen = !m3GOpen;
        Settings.setBoolean(this, Settings.KEY_PREF_3G_AUTO_PLAY, m3GOpen);
        m3GView.setImageResource(m3GOpen ? R.mipmap.setting_check_on : R.mipmap.setting_check_off);
    }
}
